package com.hy.study.search;

/**
 * 顺序线性查找
 */
public class SeqSearch {
    public static void main(String[] args) {
        int arr[]={9,5,4,2,5,2,3,4,5,1};
        int i = seqSearch(arr, 3);
        System.out.println(i);
    }

    /**
     * 逐一比较，返回找到的
     * @param arr
     * @param value
     * @return
     */
    public static  int seqSearch(int arr[] ,int value){
        for (int i = 0; i < arr.length; i++) {
            if(value==arr[i]){
                return i;
            }

        }
        return -1;
    }
}
